<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="../css/stylesite.css" medial="all" />
<link rel="stylesheet" type="text/css" href="../css/styleleft.css" medial="all" />
<link rel="stylesheet" type="text/css" href="../css/style.css" media="all" />
	<script src="../js/jquery-1.8.2.min.js" ></script>
	<script src="../js/image.js" type="text/javascript"></script>
        <script src="../js/jsearch.js" type="text/javascript"></script> 
	<script type="text/javascript">
	function filltext (id,role, name,pass,email)
	{
		document.getElementById("userid").value=id;
		document.getElementById("Role").value=role;
		document.getElementById("txtName").value=name;
		document.getElementById("txtPass").value=pass;
		document.getElementById("txtEmail").value=email;
		
	}
	</script>
<title>Trang chủ Admin</title>
</head>

<body class="pagebody">

	<div id="wrapwebsite" >
				<?php 
			include('../element/header_adm.php');
			if(!isset($_SESSION['user'])|| $_SESSION['user'][4]!='admin')
				{
				header ('location:/cfshop/home.php');
				}
			 include('m_user.php'); ?>
			<div class="imagestop"></div>
			<div class="wrapmaincontent">
			<div class="frmedit">
			<form action="c_user.php" method="post">
			<input type="hidden" id="userid" name="userid"/>
			<div class="settingrow">
			UserName:<input type="text" id="txtName" name="txtName" size="30"/><br></div>
			<div class="settingrow">Password: <input type="text" id="txtPass" name="txtPass" size="30"/><br></div>
			<div class="settingrow">Email : &nbsp;&nbsp;&nbsp;&nbsp;  <input id="txtEmail" type="text" name="txtEmail" size="30"/><br></div>
			<div class="settingrow">Role :&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <select id="Role" name="Role">
			<?php
				$roles= getAllRole();
				foreach ($roles as $role)
				{
			 ?>
			 <option value="<?php echo $role[0]; ?>"><?php echo $role[1]; ?> </option>
			<?php } ?>
			</select><br></div>
			<div class="settingrow"><input class="button" type="submit" value="Save" name="edit"/></div>
			
			</form>
			</div>
			<div class="listuser">
			<span> Danh sách user :</span>
			<div class="row">
			<div class="tstt" >STT</div>
			<div class="tname" >UserName</div>
			<div class="tpass" >Password</div>
			<div class="temail" >Email</div>
			<div class="trole" >RoleID</div>
			<div class="tstt" >Edit</div>
			<div class="tstt" >Delete</div>
			</div>
			
			
			<?php $users=getAllUser();$stt=1;
			foreach ($users as $user)
			{ ?>
				<div class="row">
				<div class="stt" ><?php echo $stt; ?></div>
				<div class="name" ><?php echo $user[1]; ?></div>
				<div class="pass" ><?php echo $user[2]; ?></div>
				<div class="email" ><?php echo $user[3]; ?></div>
				<div class="role" ><?php if($user[4]!=null) echo $user[4]; else echo 'null'; ?></div>
				<div class="stt" ><img src="images/edit_user.png" style="cursor:pointer" width="20px" height="17px" onClick=" filltext ('<?php echo $user[0];?>','<?php echo $user[4];?>', '<?php echo $user[1]?>', '<?php echo $user[2]; ?>','<?php echo $user[3];?>')"/></div>
				<div class="stt" ><form action="c_user.php" method="post" ><input type="hidden" value="<?php echo $user[0];?>" name="id"/><input type="submit" style="background:url(images/Delete.png) no-repeat; border:none; height:17px; cursor:pointer;" name="delete"  value=" " /></form></div>
				</div>
			<?php $stt++; }?>
			</div>	
		</div> 
		
		<?php include('../element/footer.php'); ?>
</div>
</body>
</html>
